/********************************** (C) COPYRIGHT *******************************
 * File Name          : main.c
 * Author             : WCH
 * Version            : V1.0.0
 * Date               : 2020/04/30
 * Description        : Main program body.
 * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
 * SPDX-License-Identifier: Apache-2.0
 *******************************************************************************/

#include <stdio.h>
#include "debug.h"
#include "multi_button.h"
#include "config.h"

struct Button ledFlashFrequencySwitchButton;

extern int delayTime;


int main(void)
{
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
    Delay_Init();
    USART_Printf_Init(115200);

    printf("SystemClk:%d\r\n", SystemCoreClock);
    printf("GPIO Module TEST\r\n");

    GPIO_ReadButtonLevel_INIT();
    GPIO_ControlLedLevel_INIT();

    button_init(&ledFlashFrequencySwitchButton,Read_Button_GPIO, 0);
    button_start(&ledFlashFrequencySwitchButton);
    button_attach(&ledFlashFrequencySwitchButton, PRESS_DOWN,Button_Callback);

    while(1) {
        GPIO_WriteBit(GPIOA, GPIO_Led, Bit_SET);
        Delay_Ms(delayTime);
        GPIO_WriteBit(GPIOA, GPIO_Led, Bit_RESET);
        Delay_Ms(delayTime);
    }
}
